/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UI;

/**
 *
 * @author Manik
 */
public class NodeData {
    
    private DataLogic.TypeInfo type_info_obj;
    private String field_name;
    private javax.swing.tree.DefaultMutableTreeNode container_obj;
    private Number num_elems;
    
    public NodeData(DataLogic.TypeInfo type_info_obj, javax.swing.tree.DefaultMutableTreeNode container_obj) {
        this.type_info_obj = type_info_obj;
        this.container_obj = container_obj;
        field_name = "Un-Named";
        num_elems = 1;
    }
    
    public javax.swing.tree.DefaultMutableTreeNode get_container_node() {
        return container_obj;
    }
    
    @Override public String toString() {
        
        String ret_value;
        if (type_info_obj.get_type() == DataLogic.TypeEnums.DATA_TYPE) {
            DataLogic.SchemaInfo schema_info = (DataLogic.SchemaInfo)type_info_obj;
            if (container_obj.getLevel() == 2) {
                // Top level schema
                ret_value = type_info_obj.get_name();
                if (num_elems.longValue() > 1) {
                    ret_value = ret_value + "[" + num_elems.toString() + "]";
                }
            } else {
                // Sub-type
                ret_value = field_name + "(" + type_info_obj.get_name();
                if (num_elems.longValue() > 1) {
                    ret_value = ret_value + "[" + num_elems.toString() + "]";
                }
                ret_value = ret_value + ")";
            }
        } else {
            ret_value = type_info_obj.get_name();
        }
        
        return ret_value;
    }
    
    public DataLogic.TypeInfo get_type_info() {
        return type_info_obj;
    }
    
    public void set_field_name(String name) {
        field_name = name;
    }
    
    public Number get_elements() {
        return num_elems.longValue();
    }
    
    public void set_elements(Number elems) {
        num_elems = elems;
    }
}
